package com.smh.controller;

import com.smh.common.CommonResult;
import com.smh.entity.DeviceData;
import com.smh.service.DeviceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@CrossOrigin
@RestController
@RequestMapping("deviceData")
public class DeviceDataController {
    @Autowired
    private DeviceDataService deviceDataService;
    //查询所有数据
    @RequestMapping(value = "queryAll",method = RequestMethod.GET)
    public CommonResult<ArrayList<DeviceData>> query(){
        return deviceDataService.queryAll();
    }

    //添加设备
    @RequestMapping(value = "add",method = RequestMethod.POST)
    public CommonResult<DeviceData> add(@RequestBody DeviceData deviceData) {
        return deviceDataService.add(deviceData);
    }

    //修改设备数据
    @RequestMapping(value = "update",method = RequestMethod.POST)
    public CommonResult<DeviceData> update(@RequestBody DeviceData deviceData) {
        return deviceDataService.update(deviceData);
    }

    //删除数据
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    public CommonResult<DeviceData> delete(Integer id){
        return deviceDataService.delete(id);
    }

    //根据id查询
    @RequestMapping(value = "queryById",method = RequestMethod.POST)
    public CommonResult<DeviceData> queryById(Integer id){
        return deviceDataService.queryById(id);
    }

}
